home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / ip / ka9q / xobbs.arc / xocmd.c < prev    next >
C/C++ Source or Header  |  1989-05-03  |  5KB  |  168 lines

  1. /*XOCMD.C Command parsing/execution module for XOBBS. Jim Durham, W2XO 04-16-89*/
  2. /*Version 1.4 */
  3. /*Code released to the amateur radio community*/
  4.  
  5. #include "xobbs.h"
  6.  
  7. parse()
  8. {
  9.     int i,j;
  10.     char *cp;
  11.     
  12.     for(i=0;i<10;i++)
  13.         command.fld[i][0] = '\0';      /*blank the command structure*/
  14.  
  15.     command.opt=' ';
  16.  
  17.     command.func=inline[0];             /*first letter is command*/
  18.  
  19.     if(inline[0]=='['){
  20.         revfwd=true;
  21.         return(0);
  22.     }
  23.  
  24.     switch(inline[1])
  25.     {
  26.         case ' ':   i=1;                /*point to the blank 2nd char*/
  27.                     break;
  28.         case '\0':  return 1;           /* done, go back*/
  29.                     break;
  30.         
  31.         default:    command.opt=inline[1];   /*assign option*/
  32.             i=2;
  33.             break;
  34.     }    
  35.     
  36.     j=1;
  37.     while(j < 10 )
  38.     {
  39.         while(inline[i]==' ') i++;          /*ratchet past any blanks*/
  40.         if(inline[i]=='\0') return 1;        /*ok if just blanks ends the line*/
  41.         cp=command.fld[j];                   /*point to the first field*/
  42.         while(inline[i] != ' ' && inline[i]) /*while not EOL or blank*/
  43.             *cp++ =inline[i++];               /*copy chars to field*/
  44.         *cp='\0';
  45.         j++;
  46.     }
  47.     return 1;
  48. }
  49.  
  50. docmd()
  51. {
  52.     char cmdstr[40];
  53.     if(!fwding){
  54.         switch(command.func)
  55.         {
  56.             case '[':   revfwd=true;
  57.                     break;
  58.             case 'U':
  59.             case 'u':   sprintf(cmdstr,"%s%s",filedir,command.fld[1]);
  60.                         upload(cmdstr);
  61.                         break;
  62.             case 'D':
  63.             case 'd':   sprintf(cmdstr,"%s%s",filedir,command.fld[1]);
  64.                         download(cmdstr);
  65.                         break;
  66.             case 'K':
  67.             case 'k':   switch(command.opt){
  68.                             case 'M':
  69.                             case 'm':   killmine();
  70.                                         break;
  71.                             default:    killmsg();
  72.                                         break;
  73.                         }
  74.                         break;
  75.             case 'S':
  76.             case 's':   sendmsg(0);
  77.                         if(dpid != 0) kill(dpid,16);   /*tell the maildaemon to do its thing*/
  78.                         break;
  79.             case 'R':
  80.             case 'r':   readmail();
  81.                         break;
  82.             case 'W':
  83.             case 'w':    sprintf(cmdstr,"%s%s",filedir,command.fld[1]);
  84.             if(command.fld[1][0] == '\0')
  85.                             dodir(cmdstr,0);
  86.             else
  87.                 dodir(cmdstr,1);
  88.                     break;
  89.             case 'L':
  90.             case 'l':   lsthdrs();
  91.                     break;
  92.             case 'F':
  93.             case 'f':   if(command.opt == '>')
  94.                             dofwd();
  95.                     else
  96.                         makefil();
  97.                         break;
  98.         case 'B':
  99.             case 'b':
  100.             case 'Q':
  101.             case 'q':   
  102.             sndupkil();
  103.                 break;
  104.  
  105.         case 'I':
  106.         case 'i':   sprintf(cmdstr,"%sinfo.xo",homedir);
  107.                 download(cmdstr);
  108.                 break;
  109.         case 'M':
  110.         case 'm':    sendmsg(1);
  111.                         if(dpid != 0) kill(dpid,16);   /*tell the maildaemon to do its thing*/
  112.                 break;
  113.             case 'N':
  114.             case 'n':   doname(command.fld[1]);
  115.                         break;
  116.             case 'E':
  117.             case 'e':   if((command.opt=='U') || (command.opt=='u'))
  118.                 edituser(command.fld[1]);
  119.                         break;
  120.         case 'H':
  121.         case 'h':    sprintf(prinbuf,"Select the Type of Help\n\n");
  122.                 prinout(NOFLUSH);
  123.                 sprintf(prinbuf,"D. Help with Downloading Files\n");
  124.             prinout(NOFLUSH);
  125.             sprintf(prinbuf,"K. Help with Killing Messages\n");
  126.             prinout(NOFLUSH);
  127.             sprintf(prinbuf,"L. Help with Listing Messages\n");
  128.             prinout(NOFLUSH);
  129.             sprintf(prinbuf,"R. Help with Reading Messages\n");
  130.             prinout(NOFLUSH);
  131.             sprintf(prinbuf,"S. Help with Sending Messages\n");
  132.             prinout(NOFLUSH);
  133.             sprintf(prinbuf,"U. Help with Uploading Files\n");
  134.             prinout(NOFLUSH);
  135.             sprintf(prinbuf,"W. Help with File Directories\n\n");
  136.             prinout(NOFLUSH);
  137.             sprintf(prinbuf,"**Type Letter of Function Selected**\n");
  138.             prinout(FLUSH);
  139.             getline();
  140.             strcpy(cmdstr,homedir);
  141.             switch(inline[0]){
  142.                 case 'D': strcat(cmdstr,"download.hlp");
  143.                     break;
  144.                 case 'K': strcat(cmdstr,"killmesg.hlp");
  145.                     break;
  146.                 case 'L': strcat(cmdstr,"listmesg.hlp");
  147.                         break;
  148.                 case 'R': strcat(cmdstr,"readmesg.hlp");
  149.                         break;
  150.                 case 'S': strcat(cmdstr,"sendmesg.hlp");
  151.                         break;
  152.                 case 'U': strcat(cmdstr,"upload.hlp");
  153.                         break;
  154.                 case 'W': strcat(cmdstr,"filedir.hlp");
  155.                         break;
  156.             }
  157.             download(cmdstr);
  158.             break;
  159.  
  160.                 default:    printerr();
  161.                     break;
  162.         }
  163.     }
  164.     else
  165.         confwd();       /*this is a forwarding session, so do it! */
  166. }
  167.  
  168.